-
Notifications
You must be signed in to change notification settings - Fork 3
Add @JsonIgnore to prevent circular reference #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdded Jackson annotations to the User model to control JSON serialization behavior. The Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/java/org/justjava/gymcore/model/User.java (1)
47-49:@JsonIgnorefixes recursion but globally hides bookings from User JSONAnnotating
bookingswith@JsonIgnoreis a straightforward way to prevent the circular reference and should resolve the serialization recursion you described. The tradeoff is thatUserJSON will now never includebookings, even on endpoints where it might be useful.If you later need
bookingsin some responses, consider:
- Using DTOs for user payloads, or
- Using Jackson features like
@JsonManagedReference/@JsonBackReferenceor@JsonIdentityInfoto break the cycle more selectively.For this PR’s stated goal (eliminate circular reference), the change looks good.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/java/org/justjava/gymcore/model/User.java(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (1)
src/main/java/org/justjava/gymcore/model/User.java (1)
4-5: Imports align with new serialization behaviorAdding the Jackson imports here is consistent with the new
@JsonIgnoreusage onbookingsand keeps concerns localized to the model. No issues from a correctness standpoint.
|
I know from first line it looks okay to merge this but I wonder is it possible to change the architecture to not to give jsonignore, I am thinking maybe there is a better approach thats why I am asking. |
|
I was wondering the same as well. I'm currently looking up ways around this because using @jsonignore can hinder future functionality |
circular reference was present in calls including bookings/user objects.
@JsonIgnore ignores the bookings field in User class.
Tests ok
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.